< previous page page_83 next page >

Page 83
Note
You could just as easily have made the getter and setter methods
Property Get and Set methods instead of functions. However, for simplicity, Property methods were not used in this example.

The BankAccountProduct interface class has the following members:
Public Function getName()
Public Sub setName(argNewValue As String)
These getter and setter methods don't do anything because this is a pure interface class. Finally, each specialized product method invoked in the createAccount method uses the actual product classes such as BasicPersonalChecking, BasicPersonalSavings, PersonalCheckingPlus, and PersonalSavingsPlus. These classes implement the BankAccountProduct interface class; they have the interface's methods in common. In the BankAccountProduct_setName and BankAccountProduct_getName interface methods, a modular variable m_pName references the type name of the actual product class. This variable is set in the Class_Initialize event. Figure 3.5 shows a model of the classes that are active in the Factory pattern.
12180-0083a.gif
Figure 3.5.
The Factory pattern is helpful for controlling the instantiation of objects.
Tip
Keep in mind, though, that you can place code inside methods in pure interface classes. That way, if another class implements it and doesn't want to override a method but wants to use it instead, you call that method in the implementing class.
Say you have a Parent class that has a method changeDiapers. Then you have a Mommy class that implements Parent but also has a private method

(text box continued on next page)

 
< previous page page_83 next page >

If you like this book, buy it!